package com.heima.kafka.consumer;

import com.alibaba.fastjson.JSON;
import com.heima.kafka.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/2/4 14:39
 * @Version 1.0
 */
@Component
public class MessageListenter {

    @KafkaListener(topics = "topic-news1")
    public void onMessage(String message){
        System.out.println("收到消息:" + message);
        User user = JSON.parseObject(message, User.class);
        System.out.println(user.toString());
    }
}